package com.theima.socket.socketdemo5;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @program: Myset
 * @description:  和单播接受端一样
 * @author: xuejingjing
 * @create: 2021-06-25 22:11
 **/
public class ServerDemo {
    public static void main(String[] args) throws IOException {
           DatagramSocket  ds =  new DatagramSocket();
               //这行代码啥意思？
              DatagramPacket dp = new DatagramPacket(new byte[1024],1024);
                 ds.receive(dp);
        byte[] data = dp.getData();
        int length = dp.getLength();
        System.out.println(new String(data,0,length));
        ds.close();
    }
}
